<template>
	<view>
		<view class="middle-title">人生建议报告</view>
		<!-- 基础信息 -->
		<view class="content-wrap flex-center" style="margin-bottom: 50rpx;">
			<view class="content-box flex-column">
				<view class="title-wrap flex-center">
					<image src="https://ydh5res.onlineweixin.com/cy2/bzinfo_files/base_01.png" class="base-title">
					</image>
				</view>
				<view class="row flex-row">
					<text class="col-l flex-row-2">
						姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<text class="em">{{orderDetail.dataMore.username}}</text>
					</text>

				</view>
				<view class="row flex-row">
					<text class="col-l flex-row-2">
						性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：<text class="em">{{orderDetail.dataMore.genderCn}}</text>
					</text>
				</view>
				<view class="row flex-row">
					<text class="col-l flex-row-2">
						年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：<text class="em">{{currentYear - orderDetail.dataMore.y}}岁</text>
					</text>
				</view>
				<view class="row flex-row" style="justify-content: flex-start;">
					<view style="color: #cac5fb; width: 200rpx;">公历出生年月：</view> 
					<view v-if="orderDetail.dataMore.h === '-1'" style="flex:1;color: #c6c4db; font-size: 16px;">{{orderDetail.dataMore.y}}年{{orderDetail.dataMore.m}}月{{orderDetail.dataMore.d}}日
					未知时</view>
					<view v-else style="flex:1;color: #c6c4db; font-size: 16px;">{{orderDetail.dataMore.y}}年{{orderDetail.dataMore.m}}月{{orderDetail.dataMore.d}}日
					{{ hh[orderDetail.dataMore.h] }}时</view>
				</view>
				<view class="row flex-row" style="justify-content: flex-start;">
					<view style="color: #cac5fb;width: 200rpx;">
						农历出生年月：
					</view>
					<view style="flex: 1; color: #c6c4db; font-size: 16px;">{{orderDetail.dataMore.lDate}}</view>
				</view>
			</view>
		</view>
		<!-- 冥想音乐 -->
		<view class="content-wrap flex-center" style="margin-bottom: 50rpx;" @click="handleMingxiangArea">
			<view class="content-box flex-column">
				<view class="title-wrap flex-center">
					<image src="https://ydh5res.onlineweixin.com/cy2/bzinfo_files/minxiang.png" class="base-title">
					</image>
				</view>
				<view class="audio-wrap">
					<luch-audio :src="audioUrl" :play.sync="audioPlay" author="适合你放松或助眠的专属轻音乐" name="冥想音乐" :autoplay="false"
						:loop="true"></luch-audio>
				</view>
			</view>
		</view>
		<!-- 按钮组 -->
		<view class="btn-wrap">
			<view class="btn btn-one" @click="toPage('/pages/report/result?ac=xingzuo&type=hunlian&oid=' +oid)">
				查看提升婚恋关系的建议</view>
			<view class="btn btn-two" @click="toPage('/pages/report/result?ac=xingzuo&type=shiye&oid=' +oid)">
				查看提升健康状态的建议</view>
			<view class="btn btn-three" @click="toPage('/pages/report/result?ac=xingzuo&type=jiankang&oid=' +oid)">
				查看提升事业发展的建议</view>
			<view v-if="orderDetail.kunHuo" class="btn btn-four"
				@click="toPage('/pages/report/result?ac=xingzuo&type=kunhuo&oid=' +oid)">查看关于当下困惑的建议</view>
		</view>
	</view>
</template>

<script>
	import {
		toPage
	} from "../../tools";
	import {
		APPID
	} from "../../config";
	import {
		getOrderInfo,
		getShowAsk
	} from '../../api'
	export default {
		data() {
			return {
				hh: ["00:00-00:59早子", "01:00-01:59丑", "02:00-02:59丑", "03:00-03:59寅", "04:00-04:59寅",
					"05:00-05:59卯", "06:00-06:59卯", "07:00-07:59辰", "08:00-08:59辰", "09:00-09:59巳", "10:00-10:59巳",
					"11:00-11:59午", "12:00-12:59午", "13:00-13:59未", "14:00-14:59未", "15:00-15:59申", "16:00-16:59申",
					"17:00-17:59酉", "18:00-18:59酉", "19:00-19:59戌", "20:00-20:59戌", "21:00-21:59亥", "22:00-22:59亥",
					"23:00-23:59晚子"
				],
				showAsk: false, // 困惑按钮
				orderDetail: {}, // 订单详情
				audioUrl: '', // 音频地址
				audioPlay: true, // 是否播放冥想音乐
				oid: '', // 订单id
				currentYear: '', // 当前年份
			}
		},
		onLoad(options) {
			this.oid = options.oid
		},
		onShow() {
			this.getDate()
			this.getOrderDetail()
			this.getKunhuoStatus()
		},
		methods: {
			// 点击冥想区域控制音乐播放/暂停
			handleMingxiangArea() {
				this.audioPlay = !this.audioPlay
			},
			// 获取当前是哪一年
			getDate() {
				const date = new Date()
				const year = date.getFullYear()
				this.currentYear = year
			},
			// 获取困惑开关
			async getKunhuoStatus() {
				const res = await getShowAsk({
					appid: APPID
				})
				if (res.status === 200) {
					this.showAsk = res.data === 1 ? true : false
				}
			},
			// 获取订单详情
			async getOrderDetail() {
				const res = await getOrderInfo({
					oid: this.oid
				})

				if (res.status === 200) {
					this.audioUrl = res.data.xingZuoMusic
					this.orderDetail = res.data
				}
			},
			toPage,
		}
	}
</script>

<style>
	page {
		background-color: #201e3e;
	}
</style>

<style scoped>
	.middle-title {
		width: 750rpx;
		height: 150rpx;
		line-height: 150rpx;
		text-align: center;
		font-size: 60rpx;
		color: #fff;
		letter-spacing: 2px;
	}

	.content-wrap {
		position: relative;
		z-index: 3;
		width: 720rpx;
		margin: 0 auto;
	}

	.flex-center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.flex-row {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.flex-row-2 {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
	}

	.content-wrap .content-box {
		width: 700rpx;
		padding: 20rpx;
		border-radius: 10rpx;
		border: 2px solid #524f7e;
		background-color: #262448;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: flex-start;
	}

	.title-wrap {
		position: relative;
		width: 100%;
		z-index: 2;
	}

	.base-title {
		display: block;
		width: 300rpx;
		height: 70rpx;
		margin: 10rpx 0 50rpx 0;
	}

	.first-title {
		display: block;
		width: 748rpx;
		height: 140rpx;
		margin: 40rpx auto;
	}

	.row {
		width: 100%;
		margin-bottom: 40rpx;
	}

	.row:last-child {
		margin-bottom: 0rem;
	}

	.row .col-l {
		width: 55%;
		color: #cac5fb;
		line-height: 1.4;
	}

	.row .col-r {
		width: 45%;
		color: #cac5fb;
		line-height: 1.4;
	}

	.row .em {
		color: #c6c4db;
		font-size: 16px;
		line-height: 1.4;
	}

	.audio-wrap {
		width: 100%;
	}

	.banner-wrap {
		width: 100%;
		position: relative;
		z-index: 1;
	}

	.banner-wrap .xingzuo-wrap {
		position: absolute;
		width: 100%;
		top: 0;
		left: 0;
		padding: 40rpx 40rpx 0 40rpx;
	}

	.banner-wrap .xingzuo-name {
		display: block;
		width: 350rpx;
		height: 80rpx;
	}

	.banner-wrap .banner {
		display: block;
		width: 750rpx;
		height: 185rpx;
	}

	.btn {
		width: 720rpx;
		height: 110rpx;
		border: 1px #262448 solid;
		font-size: 40rpx;
		text-align: center;
		line-height: 110rpx;
		margin: 0 auto 50rpx;
		border-radius: 20rpx;
		animation: big 2s linear infinite;
	}

	.btn-one {
		background-color: #409eff;
		color: #fff;
	}

	.btn-two {
		background-color: #67c23a;
		color: #fff;
	}

	.btn-three {
		background-color: #e6a23c;
		color: #fff;
	}

	.btn-four {
		background-color: #f56c6c;
		color: #fff;
	}
</style>